package io.github.maojian.temp;

import org.junit.Test;

import java.util.Arrays;

/**
 * @Auther: jian.mao
 * @Date: 2022-07-06 09:38
 * @Description:
 */
public class BurgerSales {
    /**
     * 计算餐厅能赚取的最大硬币数，本方法按照竞赛题目要求完成
     * @param coins 给定n个顾客所拥有的硬币数量
     * @return 计算出来的餐厅能赚取的最大硬币数
     */
    public int maxIncomes(int[] coins) {
        Arrays.sort(coins);
        int length = coins.length;
        int maxCoinCount = Integer.MIN_VALUE;
        for (int i = 0; i < length; i++) {
            maxCoinCount = Math.max(maxCoinCount, coins[i] * (length - i));
        }
        return maxCoinCount;
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int[] coins = new int[]{1, 1, 1};
        BurgerSales solution = new BurgerSales();
        solution.maxIncomes(coins);
    }

    @Test
    public void test01() {
        int[] coins = new int[]{4, 1, 1, 1};
        System.out.println(maxIncomes(coins));
    }
}
